﻿package pk;

class MyThread extends Thread{        
          private int ticket = 5 ;               
          public void run(){        
                  for(int i=0;i<100;i++){
                         if(this.ticket>0){
                                 System.out.println("卖票：ticket = " + ticket--) ;
                          }
                  }
          }
 };
 public class ThreadDemo0{
        public static void main(String args[]){
                 MyThread mt1 = new MyThread() ;         
                 MyThread mt2 = new MyThread() ;         
                MyThread mt3 = new MyThread() ;         
                 mt1.run() ;       
                 mt2.run() ;      
                mt3.run() ;       
         }
 };
 
 
 class MyThread implements Runnable{        
         private int ticket = 5 ;                
         public void run(){       
                 for(int i=0;i<100;i++){
                         if(this.ticket>0){
                                 System.out.println("卖票：ticket = " + ticket--) ;
                         }
                 }
         }
 };
 public class RunnableDemo0{
         public static void main(String args[]){
                 MyThread mt = new MyThread() ;         
                 new Thread(mt).run() ;        
                 new Thread(mt).run() ;        
                 new Thread(mt).run() ;       
         }
 };